
const BaseService = require("./base_service.js");
const SystemConfigModel = require('../model/system_config_model.js');

class SystemConfigService extends BaseService {

    /**
     * 获取配置信息
     */
    async get_config(keys) {
        const res = {
            key: null,
            value: null,
            label: null,
            list: {},
        };
        const data = await SystemConfigModel.getAll({ 'key': { '$in': keys }}, '*', '', 100, false);

        if (data) {
            res.key = data[0].key;
            res.value = data[0].value;
            res.label = data[0].label;
            data.forEach(item => {
                res.list[item.key] = {
                    key: item.key,
                    value: item.value,
                    label: item.label,
                };
            });
        }
        return res;
    }

}

module.exports = SystemConfigService;